package com.minimalist.common.entity.basic.vo.role;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.convert.LongArrJsonSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * @author 11987
 */
@Schema(name = "角色实体")
public class RoleVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "角色ID不能为空", groups = {Update.class})
    @Schema(name = "roleId", description = "角色ID", type = "string")
    private Long roleId;

    @NotBlank(message = "角色名称不能为空", groups = {Add.class, Update.class})
    @Schema(name = "roleName", description = "角色名称", type = "string")
    private String roleName;

    @NotBlank(message = "角色编码不能为空", groups = {Add.class, Update.class})
    @Schema(name = "roleCode", description = "角色编码", type = "string")
    private String roleCode;

    @NotNull(message = "排序值不能为空", groups = {Add.class, Update.class})
    @Schema(name = "roleSort", description = "排序", type = "integer")
    private Integer roleSort;

    @NotNull(message = "角色状态不能为空", groups = {Update.class})
    @SchemaEnum(implementation = StatusEnum.class)
    @Schema(name = "status", description = "角色状态", type = "integer")
    private Integer status;

    @Schema(name = "remark", description = "备注", type = "string")
    private String remark;

    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(name = "tenantId", description = "租户ID", type = "string")
    private Long tenantId;

    @Schema(name = "checkedPermIds", description = "角色权限编码集合，用于回显", type = "array")
    private List<String> checkedPermIds;

    @JsonSerialize(using = LongArrJsonSerializer.class)
    @NotEmpty(message = "角色权限不能为空", groups = {Add.class, Update.class})
    @Schema(name = "permissionsIds", description = "角色权限编码集合，全勾选+半勾选的节点", type = "array")
    private List<Long> permissionsIds;

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleCode() {
        return roleCode;
    }

    public void setRoleCode(String roleCode) {
        this.roleCode = roleCode;
    }

    public Integer getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(Integer roleSort) {
        this.roleSort = roleSort;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public List<String> getCheckedPermIds() {
        return checkedPermIds;
    }

    public void setCheckedPermIds(List<String> checkedPermIds) {
        this.checkedPermIds = checkedPermIds;
    }

    public List<Long> getPermissionsIds() {
        return permissionsIds;
    }

    public void setPermissionsIds(List<Long> permissionsIds) {
        this.permissionsIds = permissionsIds;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RoleVO roleVO = (RoleVO) o;
        return java.util.Objects.equals(roleId, roleVO.roleId) &&
               java.util.Objects.equals(roleName, roleVO.roleName) &&
               java.util.Objects.equals(roleCode, roleVO.roleCode) &&
               java.util.Objects.equals(roleSort, roleVO.roleSort) &&
               java.util.Objects.equals(status, roleVO.status) &&
               java.util.Objects.equals(remark, roleVO.remark) &&
               java.util.Objects.equals(tenantId, roleVO.tenantId) &&
               java.util.Objects.equals(checkedPermIds, roleVO.checkedPermIds) &&
               java.util.Objects.equals(permissionsIds, roleVO.permissionsIds);
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(roleId, roleName, roleCode, roleSort, status, remark, tenantId, checkedPermIds, permissionsIds);
    }

    @Override
    public String toString() {
        return "RoleVO{" +
               "roleId=" + roleId +
               ", roleName='" + roleName + '\'' +
               ", roleCode='" + roleCode + '\'' +
               ", roleSort=" + roleSort +
               ", status=" + status +
               ", remark='" + remark + '\'' +
               ", tenantId=" + tenantId +
               ", checkedPermIds=" + checkedPermIds +
               ", permissionsIds=" + permissionsIds +
               '}';
    }

}
